import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

/*
 * 卡片基类
 */
class BaseCard extends StatefulWidget {
  @override
  BaseCardState createState() => BaseCardState();
}

class BaseCardState extends State<BaseCard> {
  //设置颜色
  Color subTitleColor = Colors.grey;
  Color bottomTitleColor = Colors.grey;

  @override
  Widget build(BuildContext context) {
    //使用 PhysicalModel进行裁切
    return PhysicalModel(
      color: Colors.transparent,
      borderRadius: BorderRadius.circular(6),
      clipBehavior: Clip.antiAlias, //设置抗锯齿
      child: Container(
        //设置白色的背景
        decoration: BoxDecoration(color: Colors.white),
        child: Column(
          //设置两种布局
          children: <Widget>[topContent(), bottomContent()],
        ),
      ),
    );
  }

  //上方布局固定
  topContent() {
    return Padding(
      padding: EdgeInsets.only(left: 20, top: 26, right: 20, bottom: 26),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: <Widget>[
          Row(
            crossAxisAlignment: CrossAxisAlignment.end,
            children: <Widget>[topTitle(''), topTitle2('')],
          ),
          //子类去实现此方法
          subTitle('')
        ],
      ),
    );
  }

  //让子类去实现底部布局
  bottomContent() {
    return Container();
  }

  subTitle(String title) {
    return Padding(
      padding: EdgeInsets.only(top: 5),
      child: Text(
        title,
        style: TextStyle(fontSize: 11, color: subTitleColor),
      ),
    );
  }

  topTitle(String title) {
    return Text(title, style: TextStyle(fontSize: 22));
  }

  //设置小标题
  topTitle2(String title) {
    return Container();
  }

  bottomTitle(String title) {
    return Text(title,
      textAlign: TextAlign.center,
      style: TextStyle(fontSize: 12, color: bottomTitleColor));
  }
}












